package cn.tedu.imop.basic.controller;

import cn.tedu.imop.api.model.RestResult;
import cn.tedu.imop.api.model.RestResultUtils;
import cn.tedu.imop.basic.entity.MemberGroup;
import cn.tedu.imop.basic.service.MemberGroupService;
import cn.tedu.imop.common.constants.Constants;
import cn.tedu.imop.common.pojo.PageData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "人群管理")
@RestController
@RequestMapping(Constants.CONTROLLER_API_VERSION+"/member/group")
public class MemberGroupController {
     private MemberGroupService memberGroupService;
     public MemberGroupController(MemberGroupService memberGroupService) {
         this.memberGroupService=memberGroupService;
     }
     //添加人群时做什么了？
     //鉴权/事务控制/记录日志/幂等/写缓存/限流/降级
     @ApiOperation("添加人群")
     @PostMapping
     public RestResult<Void> createMemberGroup(MemberGroup memberGroup) {
          memberGroupService.createMemberGroup(memberGroup);
          return RestResultUtils.success();
     }
     @ApiOperation("人群列表")
     @GetMapping
     public RestResult<PageData<MemberGroup>> getMemberGroupList(MemberGroup memberGroup) {
         return RestResultUtils.success(memberGroupService.getMemberGroupList(memberGroup));
     }
}